package room_service

import "repairs/models"

type RoomRecord struct {
	ID   int
	Room string

	PageNum  int
	PageSize int
}

func (r *RoomRecord) Add() error {
	err := models.AddRoom(r.Room)
	return err
}
func (r *RoomRecord) ExistByRoom() (bool, error) {
	return models.ExistRoom(r.Room)
}

func (r *RoomRecord) ExistById() (bool, error) {
	return models.ExistRoomById(r.ID)
}

func (r *RoomRecord) GetAll() ([]*models.RoomRecord, error) {
	rooms, err := models.GetRooms(r.PageNum, r.PageSize)
	if err != nil {
		rooms = nil
	}
	return rooms, err
}

func (r *RoomRecord) Delete() error {
	return models.DeleteRoom(r.ID)
}

func (r *RoomRecord) Count() (int, error) {
	return models.GetRoomTotal()
}
